package linear.queue;

/**
 * @Author: fzykd
 * Date: 2024-04-11
 * Time: 22:36
 * User: LQH
 */

class ListNode {
    public int val;
    public ListNode next;

    public ListNode(int val) {
        this.val = val;
    }
}

//链表实现普通队列
public class NodeQueue {

    //头节点
    public ListNode head;
    //尾节点
    public ListNode last;

    //元素个数
    public int size;

    //队列是 尾进头出

    //入队 尾巴进
    public void addTail(int key) {

    }

    //出队 头出队
    public void popFirst() {

    }

    //判空
    public boolean isEmpty() {
        return size == 0 && head == null;
    }

    //返回队首元素
    public int firstVal() {
        //判空
        if (isEmpty()) {
            return -1;
        }
        return head.val;
    }

    //返回队尾元素
    public int lastVal() {
        if (isEmpty()) {
            return -1;
        }
        return last.val;
    }

    //返回元素个数
    public int size() {
        return size;
    }


}
